import { Breadcrumb } from "antd";
import { useLocation } from "react-router-dom";
import { getRouteName } from './routeName'

const Breadcrumbs = () => {
  let historyPathList = useLocation()
    .pathname.split("/")
    .filter((item) => item);
  let items = [];
  historyPathList.forEach((item) => {
    const obj = {
      path: '/' + item,
      title: getRouteName(item)
    };
    items.push(obj);
  });
  return (
    <Breadcrumb
      separator=">"
      items={items}
    />
  );
};

export default Breadcrumbs;
